package org.vectrics.recruiter.job.event;

import java.util.Locale;
import org.vectrics.event.Event;
import org.vectrics.event.EventEmailBuilder;
import org.vectrics.mail.EmailHtmlBase;
import org.vectrics.mail.MailMessage;
import org.vectrics.provider.CoreServiceLocator;
import org.vectrics.recruiter.user.Interview;

public class InterviewEmailBuilder extends EventEmailBuilder {
	private Interview interview = null;

	public InterviewEmailBuilder(Event event, Interview interview, Locale locale) {
		super(event, locale);
		this.interview = interview;
	}
	
	public boolean supportsHtml() {
		return(true);
	}
	
	protected String getEmailFromName() {
		String from = CoreServiceLocator.getSystemService().getStringSystemConstant("mail.from.name", interview.getDomain());
		return(from);
	}
	
	protected EmailHtmlBase createHtmlEmail() {
		InterviewHtmlEmail email = new InterviewHtmlEmail(this.getLocale(), this.interview);
		return(email);
	}

	public MailMessage getTextMailMessage() {
		MailMessage message = new MailMessage(this.getDomain());
		message.setContentType(MailMessage.CONTENT_TEXT);
		message.setBody("Modification of interview: " + interview.getDescription());
		message.setFromName(this.getEmailFromName());
		message.setSubject(getSubject());
		return(message);
	}
	
	
	
	public String getSubject() {
		String subject = this.getPhrase("email.subject.interview.changed") + ": "  + 
			this.interview.getPerson().getName();
		return(subject);
	}

}
